<template>
  <div class="LoginPage">
    <div class="top">
      <span class="fh"><van-icon name="arrow-left" @click="fh" /></span>
      <span>个人中心</span>
      <van-icon name="setting-o" class="sz" @click="goSetting" />
    </div>
    <div class="mainCenter">
      <div class="login">
        <van-image
          round
          width="85"
          height="85"
          src="https://img01.yzcdn.cn/vant/cat.jpeg"
          class="touxiang"
        />
        <span class="djdl" @click="denglu" v-if="ishow">请登录账号 </span>
        <span class="djdl" v-else-if="!ishow" @click="goIndex"
          >欢迎您：{{ username }}</span
        >
      </div>
      <div class="fu">
        <van-grid>
          <van-grid-item icon="gold-coin-o" text="待付款" @click="goMenue"/>
          <van-grid-item icon="shop-o" text="待收货" />
          <van-grid-item icon="thumb-circle-o" text="待评价" />
          <van-grid-item icon="orders-o" text="全部订单" />
        </van-grid>
      </div>
      <div>
        <van-cell center title="地址管理" is-link to="Address" class="cell" />
        <van-cell center title="我的收藏夹" is-link to="Collect" class="cell" />
        <van-cell center title="关于我们" is-link to="AboutUs" class="cell" />
      </div>
      <div class="gray"></div>
    </div>
    <FooterBar class="fot"></FooterBar>
  </div>
</template>

<script>
import FooterBar from "../components/FooterBar.vue";
export default {
  name: "Mine",
  data() {
    return {
      username: "",
      ishow: true,
    };
  },
  components: {
    FooterBar,
  },
  methods: {
    denglu() {
      this.$router.push({ path: "/Login" });
    },
    fh() {
      this.$router.go(-1);
    },
    goSetting() {
      this.$router.push({ path: "/Setting" });
    },
    goIndex() {
      this.$router.push({ path: "/Home" });
    },
    goMenue(){
      this.$router.push({ path: "/SeeMenu" });
    }
  },
  created() {
    let token = localStorage.getItem("token");
    // console.log("token: ", token);
    let userid = localStorage.getItem("userid");
    if (token) {
      this.ishow = !this.ishow;
    }
    // console.log("userid: ", userid);

    /* this.$service
      .get("/api/user/info", {
        headers: { token },
        params: { userid },
      })
      .then((res) => {
        console.log(res, "res");
        if (token) {
          this.tel = res.data.data[0].tel;
        }
        console.log("this.tel: ", this.tel);
      }); */
      this.username=localStorage.getItem("username");
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}
.LoginPage {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mainCenter {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.top {
  height: 3rem;
}
.top {
  text-align: center;
  line-height: 3rem;
  border-bottom: 2px solid gray;
  position: relative;
}
.fh {
  position: absolute;
  font-size: 20px;
  left: 1rem;
}
.login {
  height: 6.5rem;
  background-color: #f6d2d2;
  position: relative;
}
.touxiang {
  margin-top: 0.6rem;
  margin-left: 0.4rem;
}
.djdl {
  position: absolute;
  /* top: 2.5rem; */
  left: 7rem;
  height: 100%;
  line-height: 6.5rem;
}
.cell {
  border-bottom: 1px solid rgba(128, 128, 128, 0.409);
  height: 2.5rem;
  padding-left: 0.8rem;
  padding-right: 0.8rem;
  box-sizing: border-box;
}
.gray {
  flex: 1;
  background-color: rgba(128, 128, 128, 0.119);
}
.sz {
  position: absolute;
  right: 0.7rem;
  font-size: 1.3rem;
  top: 0.8rem;
}
</style>